home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Think Class Libraries / CPEditText 1.2 / CPEditTextX.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-30  |  3.3 KB  |  98 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.  CPEditTextX.h
  3.  
  4.                     Constants and Macros for the PEditText Class
  5.          
  6.     Copyright © 1992-1993 Christopher R. Wysocki.  All rights reserved.
  7.      
  8.  ******************************************************************************/
  9.  
  10. #pragma once                                    // Include this file only once
  11.  
  12. /** Constants **/
  13.  
  14. #define        rItalicIBeamCursor        1225        // Resource ID of italic i-beam cursor
  15.  
  16. #define        kDefaultTabSpaces        4            // Default number of spaces per tab
  17.  
  18. #define        kStandardGapLength        512            // Standard length of insertion gap
  19.  
  20. #define        kDefaultBoundsWidth        4096        // Default width of bounds rectangle
  21.  
  22. #define        kHorizInset                2            // Pixel inset from left of frame
  23. #define        kVertInset                0            // Pixel inset from top of frame
  24.  
  25. #define        kBackspace                (Byte)'\b'    // ASCII character codes
  26. #define        kTab                    (Byte)'\t'
  27. #define        kReturn                    (Byte)'\r'
  28. #define        kLineFeed                (Byte)'\n'
  29. #define        kFormFeed                (Byte)'\f'
  30. #define        kSpace                    (Byte)' '
  31.  
  32. #define        kInvisSpace                (Byte)'◊'    // Characters for "show invisibles"
  33. #define        kInvisTab                (Byte)'Δ'
  34. #define        kInvisReturn            (Byte)'¬'
  35. #define        kInvisLineFeed            (Byte)'£'
  36. #define        kInvisFormFeed            (Byte)'ƒ'
  37. #define        kInvisOther                (Byte)'¿'
  38.  
  39. // mnemonic constants for Boolean parameters
  40. enum {
  41.     kEraseText = TRUE,
  42.     kDontEraseText = FALSE,
  43.     kUseSelection = TRUE,
  44.     kDontUseSelection = FALSE
  45. };
  46.  
  47. /** Macros **/
  48.  
  49. #define        SetLongPt(lp,x,y)        (lp)->h = (x),        \
  50.                                     (lp)->v = (y);
  51.  
  52. #define        SetLongRect(lr,l,t,r,b)    (lr)->left = (l),    \
  53.                                     (lr)->top = (t),    \
  54.                                     (lr)->right = (r),    \
  55.                                     (lr)->bottom = (b);
  56.  
  57. #define        IsArrowKey(c)            ((c) == kLeftCursor || (c) == kRightCursor ||    \
  58.                                      (c) == kUpCursor || (c) == kDownCursor)
  59.  
  60. #define        IsColorPort(p)            (((CGrafPtr) p)->portVersion & 0xC000)
  61.  
  62. #define        HorizInset()            (kHorizInset + frame.left - position.h * hScale)
  63. #define        VertInset()                (kVertInset + frame.top - position.v * vScale)
  64.  
  65. #define        HorizPixelExtent()        ((bounds.right - bounds.left) * hScale)
  66. #define        VertPixelExtent()        ((bounds.bottom - bounds.top) * vScale)
  67.  
  68. // The following macros provide equivalent inline replacements for
  69. // the standard methods defined in CPane.  To make the object code
  70. // smaller but slighly slower, remove the following four #defines.
  71.  
  72. #define        FrameToQD(framePt,qdPt)                                            \
  73.         (qdPt)->h = (long)(framePt)->h - hOrigin + thePort->portRect.left,    \
  74.         (qdPt)->v = (long)(framePt)->v - vOrigin + thePort->portRect.top
  75.  
  76. #define        FrameToQDR(frameRect,qdRect)                                    \
  77.         FrameToQD(&topLeftL(*(frameRect)), &topLeft(*(qdRect))),            \
  78.         FrameToQD(&botRightL(*(frameRect)), &botRight(*(qdRect)))
  79.  
  80. #define        QDToFrame(qdPt,framePt)                                            \
  81.         (framePt)->h = (long) (qdPt).h + hOrigin - thePort->portRect.left,    \
  82.         (framePt)->v = (long) (qdPt).v + vOrigin - thePort->portRect.top
  83.  
  84. #define        QDToFrameR(qdRect,frameRect)                                    \
  85.         QDToFrame(topLeft(*(qdRect)), &topLeftL(*(frameRect))),                \
  86.         QDToFrame(botRight(*(qdRect)), &botRightL(*(frameRect)))
  87.  
  88. /** Prototypes **/
  89.  
  90. #if __cplusplus
  91. extern "C" {
  92. #endif
  93. void    AsmDrawLineRange(Ptr textP, short numChars, short tabWidth, Ptr gapP, long gapLength, Point startPt, Boolean showInvisibles);
  94. void    AsmMeasureTextWidths(Ptr textP, short numChars, short tabWidth, Ptr gapP, long gapLength, short *widthsP, short maxWidth);
  95. #if __cplusplus
  96. };
  97. #endif
  98.